package com.cn.bukeManage.service.serviceImpl;

import java.io.UnsupportedEncodingException;
import java.security.interfaces.RSAPrivateKey;
import java.sql.Date;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.cn.bukeManage.consts.PayMethod;
import com.cn.bukeManage.consts.TypeOfIndent;
import com.cn.bukeManage.dao.UserDao;
import com.cn.bukeManage.pojo.User;
import com.cn.bukeManage.service.IPayService;
import com.cn.bukeManage.utils.LuKeOrderNoUtil;


/**
 * 
 * PayServiceImpl 上午11:16:24
 * 
 * Copyright zhaocj Inc. All rights reserved. Love ME Like Justin Bieber.
 */
@Service("paySER")
public class PayServiceImpl implements IPayService {
	@Resource
	private UserDao userDao;
	@Override
	public boolean insertRecharge(HttpServletRequest request, HttpSession session, Double money) {
		User user=userDao.selectUserByName(String.valueOf(SecurityUtils.getSubject().getSession().getAttribute("userName")));
		String lukebang_order_num="";		
		if (user!=null) {
			lukebang_order_num =LuKeOrderNoUtil.getMerchantsOrderNo(user.getUserId(),
					PayMethod.ALIPAY.getIndex(), TypeOfIndent.RECHARGE.getIndex());
		}
		// 返回参数
		request.setAttribute("lukebang_tradeno", lukebang_order_num);
		request.setAttribute("lukebang_subject", "鹿客充值");
		request.setAttribute("lukebang_total_fee", String.valueOf(money));
		request.setAttribute("lukebang_body", "鹿客帮钱包充值");
		Map<String, String> extraMap = new HashMap<String, String>();
		extraMap.put("bussType", TypeOfIndent.RECHARGE.getName());
		request.setAttribute("extra_common_param", JSON.toJSONString(extraMap, SerializerFeature.UseSingleQuotes));
		return true;
	}	
}
